package com.xuzimian.globaldemo.thirdplatform.wechat.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.io.UnsupportedEncodingException;

/**
 * @program: GlobalDemo
 * @description: Rest web Api
 * @author: xzm
 * @create: 2019-01-08 16:42
 **/
@org.springframework.web.bind.annotation.RestController
public class RestApiController {

    @GetMapping("/hello")
    public String handle() {
        return "Hello WebFlux";
    }

    @GetMapping("/test")
    public Mono<ServerResponse> test()  {
        return ServerResponse
                .ok().body(BodyInserters.fromObject("{say:Hello World!}"));
    }

    @GetMapping("/index")
    public Mono<String> index() throws UnsupportedEncodingException {
        return Mono.just("Welcome to reactive world ~");
    }

}
